﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using KetBanBonPhuong;

public partial class UserControls_ListFriends : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Repeater1_PreRender(object sender, EventArgs e)
    {
        Session["UserID"] = 1;
        if (Session["UserID"] != null)
        {
            int UserID = Convert.ToInt32(Session["UserID"].ToString());
            FriendList fl = FriendList.GetInfoByUserID(UserID);
            DataTable dt = Friend.GetByFriendListID(fl.Friend_list_id);
            Repeater1.DataSource = dt;
            Repeater1.DataBind();
        }
    }
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemIndex < 0) 
        {
            return;
        }
        HyperLink avatarHyperLink = (HyperLink)e.Item.FindControl("avatarHyperLink");
        Image avatarImage = (Image)e.Item.FindControl("avatarImage");
        HyperLink nameHyperLink = (HyperLink)e.Item.FindControl("nameHyperLink");

        DataRowView row = (DataRowView)e.Item.DataItem;

        User user = User.GetInfo(Convert.ToInt32(row["friend_user_id"].ToString()));
        KetBanBonPhuong.Profile profile = KetBanBonPhuong.Profile.GetInfoByUserID(user.UserID);

        avatarImage.ImageUrl = "../Files/Avatars/" + user.Avatar;

        nameHyperLink.Text = profile.Nick_name;
        nameHyperLink.NavigateUrl = "#";
        avatarHyperLink.NavigateUrl = "#";
    }
}
